package com.sgb.goods.viewmodel;

import androidx.lifecycle.MutableLiveData;

import com.sgb.goods.api.GoodsCallBack;
import com.sgb.goods.api.GoodsNet;
import com.sgb.goods.utils.base.viewmodel.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.SharedPreferenceUtil;

/**
 * 采购订单 viewModel
 * @author cyj
 */
public class PurchaseOrderListViewModel extends BaseViewModel {

    public MutableLiveData<Integer> type = new MutableLiveData<>();

    /** 获取审批配置 */
    public void getApprovalConfig() {
        String companyNo = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.COMPANY_NO, "");
        showLoading();
        GoodsNet.getInstance().getGoodsApi().getApprovalConfig("purchaseOrder", companyNo).enqueue(new GoodsCallBack<BaseEntity<String>>() {
            @Override
            public void onSuccess(BaseEntity<String> data) {
                // 1代表配置了
                type.setValue("1".equals(data.getData()) ? 1 : 0);
            }

            @Override
            public void onFail() {
                type.setValue(0);
            }
        });
    }
}
